package com.wnxy.sddfp.trade.controller;

import com.wnxy.sddfp.trade.service.IAgencyBidService;
import com.wnxy.sddfp.trade.service.IBorrowRecordService;
import com.woniuxy.sddfp.common.model.dto.bid.AgencyBidDTO;
import com.woniuxy.sddfp.common.model.dto.trade.BorrowRecordDTO;
import com.woniuxy.sddfp.common.model.vo.bid.AgencyBidVo;
import com.woniuxy.sddfp.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 */
@RestController
@Api(tags = "交易中心控制器")
public class TradeController {

    @Autowired
    private IBorrowRecordService borrowRecordService;
    @Autowired
    private IAgencyBidService agencyBidService;

    @ApiOperation("借款申请")
    @PostMapping("/trade/borrow/add")
    public Result addBorrowRecord(@RequestBody BorrowRecordDTO borrowRecordDTO) {
        borrowRecordService.addBorrowRecord(borrowRecordDTO);
        return Result.ok();
    }

    @ApiOperation("借款审核接口,同步借款数据")
    @PutMapping("/trade/borrow/status")
    public Result verifyStatus(Integer approveStatus,Long borrowRecordId){
        String result = borrowRecordService.verifyStatus(approveStatus,borrowRecordId);
        return Result.ok(result);
    }

    @ApiOperation("机构认购")
    @PostMapping("/trade/agency/bid/add")
    public Result<AgencyBidVo> addAgencyBid(
            @RequestBody AgencyBidDTO agencyBidDTO) {
        AgencyBidVo tenderDTO=agencyBidService.addAgencyBidRecord(agencyBidDTO);
        return Result.ok(tenderDTO);
    }
}











